package com.yitiao.data_algorithms.leetcode.editor.cn;

import java.util.Arrays;

class LargestPerimeterTriangle {
    // 2023-02-20 17:19:02
    public static void main(String[] args) {
        Solution solution = new LargestPerimeterTriangle().new Solution();
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int largestPerimeter(int[] nums) {
            Arrays.sort(nums);
            for (int i = nums.length - 1; i >= 2; --i) {
                if (nums[i - 2] + nums[i - 1] > nums[i]) {
                    return nums[i - 2] + nums[i - 1] + nums[i];
                }
            }
            return 0;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}